﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataTransferObject;
namespace _5ChickDeal
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        DataClassesDataContext db;
        KhachHang kh;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Response.Redirect("~/Default.aspx");
            }
            kh = (KhachHang)Session["user"];
            HoTen.Text = kh.hoten;
            
        }

        protected void Sm_Click(object sender, EventArgs e)
        {
            if (TextBoxCurrentPassword.Text != kh.matkhau)
            {
                Label1.Text = "Sai mật khẩu";
                return;
            }
            db = new DataClassesDataContext();
            KhachHang khm = db.KhachHangs.Single(k => k.id == kh.id);
            khm.matkhau = EncoderPassword.GetMd5Hash( TextBoxNewPass1.Text);
            db.SubmitChanges();
            Label1.Text = "<span style='color:green'>Đổi mật khẩu thành công<span>";
        }
    }
}
